

import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
import router from "../route/index";
import { getRouter } from "../utils/index";
var routes = router.options.routes


export default new Vuex.Store({
  state: {
    count: 0,
    routes: [],
    user: {
      headImage: "https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTJ5GIMGQPRu3icA5MH3y67icvNcbLcmiaRy3l6yPXXn5Lc3ibXZnD0jziafZicWmUrAqFMxYgiaEA2pg6oFw/132",
      webChatName: "郭子仪",
      userId: "15",
    },
    route: "/home"
  },
  mutations: {
    increment(state) {
      state.count++
    },
    goPage(state, route) {
      if (state.route == route) {
        return
      }
      state.route = route
      vm.$router.push(route)
    },
    getRouter(state) {
      state.routes = getRouter(routes)
    }
  },
  actions: {
    increment(context) {
      context.commit('increment')
    }
  }
})